package com.brush.web.controller.sowpig;

import com.brush.common.core.controller.BaseController;
import com.brush.common.core.domain.R;
import com.brush.pig.domain.req.sow.SowQueryInformationReq;
import com.brush.pig.domain.req.sow.SowUpdateEarCodeReq;
import com.brush.pig.domain.resp.sow.SowQueryFactoryResp;
import com.brush.pig.domain.resp.sow.SowQueryInformationResp;
import com.brush.pig.domain.resp.sow.SowQueryTransferResp;
import com.brush.pig.service.IotPigService;
import com.brush.system.service.SysDeptService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api( value = "SowPigController", tags = "母猪管理")
@RestController
@RequestMapping("/admin/sowPig")
public class SowInformationController extends BaseController {

    @Autowired
    private SysDeptService sysDeptService;

    @Autowired
    private IotPigService iotPigService;

    @ApiOperation(value = "查询所有厂区")
    @GetMapping("/queryFactoryList")
    public R<List<SowQueryFactoryResp>> queryFactoryList(){
         List<SowQueryFactoryResp> resp=this.sysDeptService.getFactoryList();
         return R.ok(resp);
    }

    @ApiOperation(value = "查询所有母猪信息")
    @GetMapping("/queryInformation")
    public R<PageInfo<SowQueryInformationResp>> queryInformation(SowQueryInformationReq req){
        PageInfo<SowQueryInformationResp> resp=iotPigService.getInformation(req);
        return R.ok(resp);
    }

    @ApiOperation(value = "根据id修改母猪信息")
    @PutMapping("/updateSowById/earCode")
    public R updateSowById(SowUpdateEarCodeReq req){
        boolean flag=iotPigService.updateSowById(req);
        return super.isSuccess(flag);
    }

    //猪只转舍  Transfer

    @ApiOperation(value = "查询猪只转舍信息")
    @GetMapping("/queryTransfer")
    public R<PageInfo<SowQueryTransferResp>> queryTransfer(SowQueryInformationReq req){
        PageInfo<SowQueryTransferResp> resp=iotPigService.getTransfer(req);
        return R.ok(resp);
    }



    @ApiOperation(value = "新增猪只转舍信息")
    @PostMapping("/addTransfer")
    public R addTransfer(@RequestBody SowQueryTransferResp req){
        return R.ok();
    }

}
